﻿Imports System.Drawing
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Camstar.WebClient.FormsBuilder.WebForm
Imports Camstar.WebClient.WebServicesProxy.InSiteWebServices
Imports BusinessRule.IBusiness
Imports BusinessRule.BusinessFactory
Imports BusinessRule.DTO
Imports DatabaseAccess.DBUtility
Imports Infragistics.WebUI.UltraWebGrid

Namespace InSiteWebApplication
    Partial Class ContainerCommentEditForm
        Inherits PopupForm
        Protected Overrides Sub OnPageLoad(ByVal sender As System.Object, ByVal e As System.EventArgs)
            MyBase.OnPageLoad(sender, e)
        End Sub
        ''' <summary>
        ''' 加载数据
        ''' </summary>
        ''' <remarks></remarks>
        Protected Overrides Sub LoadData()
            Try
                If Not IsPostBack Then
                    Dim containerName As String = Session("ContainerNameByComments").ToString()
                    txtcontainerName.Value = containerName
                    initGrid(containerName)
                End If
            Catch ex As Exception
                StatusMessage.ErrorText = ex.Message
            End Try
        End Sub
        ''' <summary>
        ''' 初始化
        ''' </summary>
        ''' <remarks></remarks>
        Private Sub initGrid(ByVal containerName As String)
            Dim sql As String = String.Format("SELECT ct.containercomments FROM container ct WHERE ct.containername = '{0}'", containerName)
            Dim dt As DataTable = DatabaseHelper.Query_ReturnDatTable(sql)
            Dim comments As String = IIf(dt.Rows.Count > 0, dt.Rows(0)(0).ToString(), "")
            ContainerCommentField.TextControl.Text = comments
        End Sub
        ''' <summary>
        ''' 关闭
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="e"></param>
        ''' <remarks></remarks>
        Protected Sub CloseButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CloseButton.Click
            Try
                ClientScript.RegisterStartupScript(Me.GetType(), "NotifyParent", "<script> OnPopupWindowClosed();  window.close();</script> ")
            Catch ex As Exception
                StatusMessage.ErrorText = ex.Message
            End Try
        End Sub
        ''' <summary>
        ''' 保存
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="e"></param>
        ''' <remarks></remarks>
        Protected Sub btSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btSave.Click
            Try
                StatusMessage.Text = ""
                Dim comments As String = ContainerCommentField.TextControl.Text
                Dim containerName As String = txtcontainerName.Value
                Dim exuteEntity = New ExcuteEntity("container", ExcuteEntity.ExcuteTypeEnum.update)
                exuteEntity.ExcuteFileds = New List(Of FieldEntity) From {New FieldEntity("containercomments", comments, FieldEntity.FieldTypeEnum.Str)}
                exuteEntity.WhereFileds = New List(Of FieldEntity) From {New FieldEntity("ContainerName", containerName, FieldEntity.FieldTypeEnum.Str)}
                DatabaseHelper.ExecuteDataByEntity(exuteEntity)
                StatusMessage.Text = "保存成功"
                'CloseButton_Click(Nothing, Nothing)
            Catch ex As Exception
                StatusMessage.ErrorText = ex.Message
            End Try
        End Sub
    End Class
End Namespace
